package com.moleq.dialog;

import android.content.Context;

import com.moleq.base.MoleQBaseActivity;
import com.moleq.dialog.MessageDialog.OnClickMessageListener;

public class MessageBox {

	private static MessageDialog mMessageDialog;
	private static boolean isShowing = false;
	private static Context mContext;
	
	public static void show(Context mContext, String msg, int k) {
		
		mMessageDialog = new MessageDialog(mContext);
		mMessageDialog.setMessage(msg);
		mMessageDialog.setOnClickMessageListener(mOnClickMessageListener);
		mMessageDialog.setStyle(MessageDialog.MESSAGE_BOX_OK);
			
		if (mMessageDialog == null || mMessageDialog.isShowing())
			return;
		
	}
	
	public static void show(Context mContext, String msg) {
	
		show(mContext,msg,mOnClickMessageListener, MessageDialog.MESSAGE_BOX_OK);
	}
	
	public static void show(Context context, String msg, OnClickMessageListener listener) {
		
		show(context,msg,listener,MessageDialog.MESSAGE_BOX_OK);
		
	}
	
	public static void show(Context context,String msg,OnClickMessageListener listener,int style){
		mContext = context;
		if (mContext instanceof MoleQBaseActivity) {
			MoleQBaseActivity linstener = (MoleQBaseActivity) mContext;
			if(!linstener.mIsShowing)  {
				
				mMessageDialog = new MessageDialog(mContext);
				mMessageDialog.setMessage(msg);
				mMessageDialog.setOnClickMessageListener(listener);
				mMessageDialog.setStyle(style);
					
				if (mMessageDialog == null || mMessageDialog.isShowing())
					return;
				mMessageDialog.show();
				
			}
				
		}
		
	}
	
	public static void close(){
	
		if (mContext instanceof MoleQBaseActivity) {
			MoleQBaseActivity linstener = (MoleQBaseActivity) mContext;
			if(linstener.mIsShowing)  {
				mMessageDialog.dismiss();
			}
				
		}
	}
	
	
	private static  OnClickMessageListener mOnClickMessageListener = new OnClickMessageListener(){

		@Override
		public void onClickYes() {
		}

		@Override
		public void onClickNo() {
		
		}

		@Override
		public void onClickOK() {
			close();
		}
		
	};


}
